/*
 * Copyright 2007-2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.paoding.rose.web.var;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

public class RequestHelper {

	RequestHelper() {
	}

	public HttpServletRequest innerRequest() {
		return PrivateVar.request();
	}

	public String uri() {
		return getRequestURI();
	}

	public String getRequestURI() {
		return innerRequest().getRequestURI();
	}

	public String param(String name) {
		return getParameter(name);
	}

	public String getParameter(String name) {
		return innerRequest().getParameter(name);
	}

	public String[] params(String name) {
		return getParameterValues(name);
	}

	public String[] getParameterValues(String name) {
		return innerRequest().getParameterValues(name);
	}

	public String header(String name) {
		return getHeader(name);
	}

	public String getHeader(String name) {
		return innerRequest().getHeader(name);
	}

	public Enumeration<String> headers(String name) {
		return getHeaders(name);
	}

	@SuppressWarnings("unchecked")
	public Enumeration<String> getHeaders(String name) {
		return innerRequest().getHeaders(name);
	}

	public void attr(String name, Object value) {
		setAttribute(name, value);
	}

	public void setAttribute(String name, Object value) {
		innerRequest().setAttribute(name, value);
	}

	public Object attr(String name) {
		return getAttribute(name);
	}

	public Object getAttribute(String name) {
		return innerRequest().getAttribute(name);
	}

	public void remoteAttr(String name) {
		innerRequest().removeAttribute(name);
	}

	public Enumeration<String> attrNames() {
		return getAttributeNames();
	}

	@SuppressWarnings("unchecked")
	public Enumeration<String> getAttributeNames() {
		return innerRequest().getAttributeNames();
	}

	public String method() {
		return getMethod();
	}

	public String getMethod() {
		return innerRequest().getMethod();
	}
}
